package com.bbtShop.api;

import com.bbtShop.aop.Login;
import com.bbtShop.core.model.ApiResponse;
import com.bbtShop.core.model.Ids;
import com.bbtShop.core.model.ProductCategory;
import com.bbtShop.core.model.ProductRecode;
import com.bbtShop.service.ProductCategoryService;
import com.bbtShop.service.ProductRecodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author : manke
 * @Description
 * @Date: 2020/10/18 19:06
 */
@Api(value = "ProductCategoryController", description = "产品分类控制器")
@RestController
@RequestMapping("/ProductCategory")
public class ProductCategoryController {

    @Autowired
    private ProductCategoryService productCategoryService;

    @ApiOperation(value = "getLisProductCategory", notes = "获取产品分类列表")
    @PostMapping("/getLisProductCategory")
    @Login(permission = "ProductCategory:getLisProductCategory")
    public ApiResponse<Object> getLisProductCategory(@RequestParam(required = false) Integer pageNum,
                                                     @RequestParam(required = false) Integer pageSize,
                                                     @RequestBody ProductCategory productCategory){
        return ApiResponse.success(productCategoryService.getLisProductCategory(pageNum,pageSize, productCategory));
    }

    @ApiOperation(value = "addUpdateProductCategory", notes = "添加修改产品分类")
    @PostMapping("/addUpdateProductCategory")
    @Login(permission = "ProductCategory:addUpdateProductCategory")
    public ApiResponse<Object> addUpdateProductCategory(@RequestBody ProductCategory productCategory){
        productCategoryService.addUpdateProductCategory(productCategory);
        return ApiResponse.success();
    }

    @ApiOperation(value = "delProductCategory", notes = "删除产品分类")
    @PostMapping("/delProductCategory")
    @Login(permission = "ProductCategory:delProductCategory")
    public ApiResponse<Object> delProductCategory(@RequestBody Ids ids){
        productCategoryService.delProductCategory(ids);
        return ApiResponse.success();
    }

    @ApiOperation(value = "getProductCategoryInfo", notes = "获取产品记录详情信息")
    @GetMapping("/getProductCategoryInfo")
    @Login(permission = "ProductCategory:getProductCategoryInfo")
    public ApiResponse<ProductCategory> getProductRecodeInfo(@RequestParam Integer id){
        return ApiResponse.success(productCategoryService.getProductRecodeInfo(id));
    }
}
